<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改密码</title>
<jsp:include page="/commons/common-js.jsp"></jsp:include>
</head>
<body style="background-color: #F3F3F3">
    <div class="easyui-dialog" title="修改密码" data-options="closable:false,draggable:false" style="width:400px;height:300px;padding:10px;">
    <form id="ukeyInfoForm">
       	<div style="margin-left: 50px;margin-top: 10px;">
       	 	<div style="margin-bottom:20px">
	            <div>
	            	旧&nbsp;&nbsp;密&nbsp;&nbsp;码: <input id="password" name="password" class="easyui-textbox" type="password" style="width:200px;height:32px" data-options="iconCls:'icon-lock',required:true,validType:'length[6,18]',missingMessage:'请输入旧密码'"/>
	            </div>
	        </div>
	        <div style="margin-bottom:20px">
	            <div>
	            	新&nbsp;&nbsp;密&nbsp;&nbsp;码: <input id="newPassword" name="newPassword" class="easyui-textbox" type="password" style="width:200px;height:32px" data-options="iconCls:'icon-lock',required:true,validType:'length[6,18]',missingMessage:'请输入新密码'"/>
	            </div>
	        </div>
	        <div style="margin-bottom:20px">
	            <div>
	            	确认密码 : <input name="repassword" class="easyui-textbox" type="password" style="width:200px;height:32px" data-options="iconCls:'icon-lock',required:true,validType:'equalTo[\'#newPassword\']', missingMessage:'请再输入一次密码'"/>
	            </div>
	        </div>
	        
	        <div>
	            <a id="toUpdatePassword" class="easyui-linkbutton" iconCls="icon-ok" style="width:100px;height:32px;margin-left: 45px">修改</a>
	        </div>
       	</div>
       	</form>
    </div>
    
    <script type="text/javascript">
    	$("#toUpdatePassword").click(function(){
    		
    		var password = $("[name=password]").val();
    		var newPassword = $("[name=newPassword]").val();
    		$.ajax({
	    		type:"post",
	    		url:"/manager/toUpdatePassword",
	    		data:{"password":password,"newPassword":newPassword},
	    		success:function(data){
	        		if(data.status == 200){
	        			alert("修改成功！");
	        			 window.location.href="/"; 
	        		}else{
	        			alert(data.msg);
	        			return ;
	        		} 
	        	}
	    	});
    	});
    	
    	
    	
    	//密码校验
    	 $.extend($.fn.validatebox.defaults.rules, {
        /*必须和某个字段相等*/
        equalTo: {
						validator: function (value, param) {
						return value == $(param[0]).val(); 
					}, 
					message: '两次密码不一致' 
			}
       });

    </script>
</body>
</html>